﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Soft.Service
{


    /// <summary>
    /// 服务器日志记录器集合
    /// </summary>
    public class ServiceLogger
    {
       
        public ServiceLogger()
        {
            this.Items = new List<ServiceLoggerItem>();
        }


        /// <summary>
        /// 获取一条日志记录器
        /// </summary>
        /// <returns></returns>
        public  ServiceLoggerItem GetService()
        {
            if (this.Items.Count == 1)
            {
                return this.Items[0];
            }
            if (this.Items.Count > 1)
            {
                List<ServiceLoggerItem> items = this.Items;
                lock (items)
                {
                    this.Items.Sort((ServiceLoggerItem a, ServiceLoggerItem b) => b.LastCallTime.CompareTo(a.LastCallTime));
                    return this.Items[0];
                }
            }
            return null;
        }


        /// <summary>
        /// 日志记录器集合
        /// </summary>
        public List<ServiceLoggerItem> Items;


    }
}
